//
//  Extension+UIView.swift
//  YXYRefreshControl
//
//  Created by 袁向阳 on 16/7/1.
//  Copyright © 2016年 YXY.cn. All rights reserved.
//

import UIKit

extension UIView {
    
    // 通过响应链条判断是否有控制器
    func getViewController() -> UIViewController?{
        
        var n = nextResponder()
        repeat{
            if ((n?.isKindOfClass(UIViewController.self)) != nil){
                return n as? UIViewController
            }
            n = n?.nextResponder()
            
        }while n != nil
        
        return nil
    }
    // 控制器是否有导航条
    func isHaveNavBar (viewVC: UIViewController) -> Bool {
        if viewVC.navigationController?.navigationBar != nil {
            return true
        }else {
            return false
        }
    }
}
